package org.cloud.ext.service.impl;

import org.cloud.ext.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author xukk
 * @date 2020/3/11
 */
@Service
public class GroupServiceImpl implements GroupService {
    @Autowired
    private RestTemplate restTemplate;
    @Override
    public boolean checkGroupPush(String pushWay,String group, List<String> groupList, List<String> excludeGroupList) {
       AtomicBoolean flag= new AtomicBoolean(false);
        groupList.forEach(v->{
            String c="|"+v+"|";
            if(group.contains(c.toLowerCase())){
                flag.set(true);
            }
        });
        excludeGroupList.forEach(v->{
            String d="|"+v+"|";
            if(group.contains(d.toLowerCase())){
                flag.set(false);
            }
        });

        return flag.get();
    }
    @Retryable(value = Exception.class,maxAttempts = 2,backoff = @Backoff(delay = 2000,multiplier = 1.5))
    @Override
    public void getGroups() {

    }
}
